package test.spring.mvc.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import test.spring.mvc.IB;



public class DispatchController extends MultiActionController {
	public ModelAndView actionName(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Log log = LogFactory.getLog(this.getClass());
		log.info("------------>Controller calling Earth.  Come in Earth.");
		String msg="WebApplicationContext is Null";
		WebApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext(getServletContext());
		msg=((IB)ctx.getBean("b")).getA().foo();
		ModelAndView mav = new ModelAndView("myview");
		mav.addObject("message", msg);
		return mav;
	}

}
